#!/usr/bin/python3
#!/usr/bin/env python3
#coding=utf-8
import xlwt
import datetime

def Gen_XLS(first_name, last_name, dob, test_date, phone, gscode, value=199):
    workbook = xlwt.Workbook(encoding = 'utf-8')
    worksheet = workbook.add_sheet('My Worksheet')
    style = xlwt.XFStyle() # 初始化样式
    font = xlwt.Font() # 为样式创建字体
    font.name = 'Times New Roman'
    font.bold = True # 黑体
    #font.underline = True # 下划线
    #font.italic = True # 斜体字
    font.height= 280
    style.font = font # 设定样式

    alignment = xlwt.Alignment() # 设置字体在单元格的位置
    alignment.horz = xlwt.Alignment.HORZ_CENTER #水平方向
    alignment.vert = xlwt.Alignment.VERT_CENTER #竖直方向
    style.alignment = alignment

    #worksheet.write(0, 0, 'Unformatted value') # 不带样式的写入
    worksheet.write(8, 7, test_date, style) # 带样式的写入
    worksheet.write(8, 9, gscode, style) # 带样式的写入
    #style.num_format_str = 'M/D/YY' # options: D-MMM-YY, D-MMM, MMM-YY, h:mm, h:mm:ss, h:mm, h:mm:ss, M/D/YY h:mm, mm:ss, [h]:mm:ss, mm:ss.0
    #worksheet.write(2, 0, datetime.date.today(), style)
    worksheet.write(22, 2, first_name + " " + last_name, style) # 带样式的写入
    worksheet.write(22, 5, dob, style) # 带样式的写入
    worksheet.write(22, 7, value, style) # 带样式的写入
    worksheet.write(10, 1, first_name + " " + last_name + '\r\n' + phone, style) # 带样式的写入
    workbook.save(first_name + "_" + last_name + ".xlsx") # 保存文件


if __name__ == "__main__":
    Gen_XLS("Changcai","Xie", "1983/08/19", "2020/12/03", '18910158363',"GS20201203003", '390')
